<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>home</title>
</head>
<body>
<p>聊天室</p>
<form id="wiselyForm">
	<textarea rows="4" cols="60" name="text" id="content"></textarea>
	<input type="submit" />
</form>
<script src="https://cdn.bootcss.com/stomp.js/2.3.3/stomp.js"></script>
<script src="https://cdn.bootcss.com/sockjs-client/1.1.4/sockjs.min.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
	$("#wiselyForm").submit(function(e){
		e.preventDefault();
		var text = $("#content").val();
		sendSpittle(text);
	});
	var socket = new SockJS("/xupxQueue");
	var stompClient = Stomp.over(socket);
	stompClient.connect('guest','guest',function(frame){
		stompClient.subscribe("/user/queue/notifications",handleNotification);
	});
	function handleNotification(message){
		$("#output").append("<b>" + new Date().toLocaleDateString()+ "</b><br/><b>" + message.body + "</b><br/>")
	}
	function sendSpittle(text){
		stompClient.send("/chat",{},text);
	}
	$("#stop").click(function(){
		socket.close();
	});
</script>
<div id="output"></div>
</body>
</html>